package com.meilai.project.controller.web.report;

import com.meilai.project.controller.web.report.dto.DrawRateDetailBuildingDTO;
import com.meilai.project.controller.web.report.dto.DrawRateDetailCommonDTO;
import com.meilai.project.controller.web.report.dto.DrawRateDetailDTO;
import com.meilai.project.controller.web.report.dto.ExportBuildingAreasDetailDTO;
import com.meilai.project.controller.web.report.service.DrawRateService;
import com.meilai.project.controller.web.report.service.WeekReportService;
import com.meilai.project.controller.web.report.vo.*;
import com.meilai.project.dto.base.ApiResult;
import com.meilai.project.service.business.building.BuildingAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author xchen
 * @since 2022-04-08
 */
@RestController
@RequestMapping("api/web/report")
@Api(tags = "报表")
public class ReportController {
	@Autowired
	private WeekReportService weekReportService;

	@Autowired
	private DrawRateService drawRateService;

	@Autowired
	private BuildingAreaService buildingAreaService;

	@PostMapping("export-buildings")
	@ApiOperation("周历表-导出多个楼盘明细表")
	public void exportBuildings(HttpServletResponse response,  @ApiParam("json") @RequestBody ExportBuildingAreasDetailDTO req) {
		buildingAreaService.exportBuildingMediaPointExcel(response, req.getBuildingAreaIds());
	}

	@PostMapping("export-buildings-to-one")
	@ApiOperation("周历表-导出多个楼盘明细表d到1个excel")
	public void exportBuildingsToOneExcel(HttpServletResponse response,  @ApiParam("json") @RequestBody ExportBuildingAreasDetailDTO req) {
		buildingAreaService.exportBuildingMediaPointExcelToOneExcel(response, req.getBuildingAreaIds());
	}

	@ApiOperation(value = "周历表-总表")
	@GetMapping("week-summary")
	public ApiResult<List<WeekSummaryVO>> weekSummary() {
		return ApiResult.ok(weekReportService.weekSummary());
	}

	@ApiOperation(value = "周历表-明细表")
	@GetMapping("week-detail")
	public ApiResult<List<WeekDetailVO>> weekDetail(@ApiParam("building_area_id") @RequestParam Long building_area_id) {
		return ApiResult.ok(weekReportService.weekDetail(building_area_id));
	}

	@ApiOperation(value = "上画率-总表")
	@GetMapping("draw-rate-summary")
	public ApiResult<List<DrawRateSummaryVO>> drawRateSummary(@ApiParam("form") DrawRateDetailDTO req) {
		return ApiResult.ok(drawRateService.drawRateSummary(req));
	}

	@ApiOperation(value = "上画率-明细（通用）", notes = "适用于路名牌/综合市场/软膜灯箱/大屏/大牌/桁架")
	@GetMapping("draw-rate-detail-common")
	public ApiResult<DrawRateDetailCommonVO> drawRateDetailCommon(@ApiParam("form") DrawRateDetailCommonDTO req) {
		return ApiResult.ok(drawRateService.drawRateDetailCommon(req));
	}

	@ApiOperation(value = "上画率-楼宇")
	@GetMapping("draw-rate-detail-building")
	public ApiResult<DrawRateDetailCommonVO> drawRateDetailBuilding(@ApiParam("form") DrawRateDetailBuildingDTO req) {
		return ApiResult.ok(drawRateService.drawRateDetailBuilding(req));
	}

	@ApiOperation(value = "上画率-加油站")
	@GetMapping("draw-rate-detail-gas-station")
	public ApiResult<DrawRateDetailGasStationVO> drawRateDetailGasStation(@ApiParam("form") DrawRateDetailDTO req) {
		return ApiResult.ok(drawRateService.drawRateDetailGasStation(req));
	}

	@ApiOperation(value = "上画率-电梯智能框")
	@GetMapping("draw-rate-detail-elevator")
	public ApiResult<DrawRateDetailElevatorVO> drawRateDetailElevator(@ApiParam("form") DrawRateDetailDTO req) {
		return ApiResult.ok(drawRateService.drawRateDetailElevator(req));
	}

}
